home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sources / libxpm / libxpm34.gz / libxpm34 / xpm-3.4 / lib / XpmWrFFrP.c < prev   
C/C++ Source or Header  |  1994-03-22  |  2KB  |  61 lines

  1. /* Copyright 1989-94 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * XpmWrFFrP.c:                                                                *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Write a pixmap and possibly its mask to an XPM file                        *
  7. *                                                                             *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #include "xpmP.h"
  12. #ifdef VMS
  13. #include "sys$library:string.h"
  14. #else
  15. #if defined(SYSV) || defined(SVR4)
  16. #include <string.h>
  17. #else
  18. #include <strings.h>
  19. #endif
  20. #endif
  21.  
  22. int
  23. XpmWriteFileFromPixmap(display, filename, pixmap, shapemask, attributes)
  24.     Display *display;
  25.     char *filename;
  26.     Pixmap pixmap;
  27.     Pixmap shapemask;
  28.     XpmAttributes *attributes;
  29. {
  30.     XImage *ximage = NULL;
  31.     XImage *shapeimage = NULL;
  32.     unsigned int width = 0;
  33.     unsigned int height = 0;
  34.     int ErrorStatus;
  35.  
  36.     /* get geometry */
  37.     if (attributes && attributes->valuemask & XpmSize) {
  38.     width = attributes->width;
  39.     height = attributes->height;
  40.     }
  41.  
  42.     /* get the ximages */
  43.     if (pixmap)
  44.     xpmCreateImageFromPixmap(display, pixmap, &ximage, &width, &height);
  45.     if (shapemask)
  46.     xpmCreateImageFromPixmap(display, shapemask, &shapeimage,
  47.                  &width, &height);
  48.  
  49.     /* write to the file */
  50.     ErrorStatus = XpmWriteFileFromImage(display, filename, ximage, shapeimage,
  51.                     attributes);
  52.  
  53.     /* destroy the ximages */
  54.     if (ximage)
  55.     XDestroyImage(ximage);
  56.     if (shapeimage)
  57.     XDestroyImage(shapeimage);
  58.  
  59.      return (ErrorStatus);
  60. }
  61.